import pgzrun

WIDTH = 482
HEIGHT = 482

def get_3_cent(x):
    arr = []
    for n1 in range(1, 10):
        for n2 in range(1, 10):
            for n3 in range(1, 10):
                if n1+n2+n3 == x:
                    arr.append([n1, n2, n3])
    return arr

def get_9_palace():
    arr=get_3_cent(15)
    for i in arr:
        for j in arr:
            for k in arr:
                if len(set(i+j+k)) == 9:
                    sum1 = i[0]+j[0]+k[0]
                    sum2 = i[1]+j[1]+k[1]
                    sum3 = i[2]+j[2]+k[2]
                    sum4 = i[0]+j[1]+k[2]
                    sum5 = i[2]+j[1]+k[0]
                    if sum1 == sum2 == sum3 == sum4 == sum5 == 15: 
                        return [i,j,k]

arr=get_9_palace()
nums = []
offset = 1
num_size = 160
for i in range(3):
    for j in range(3):
        n=arr[i][j]
        r = i % 4
        c = j % 4
        num = Actor(str(n))
        num.pos = r * num_size + num_size / 2 + offset, c * num_size + num_size / 2 + offset
        nums.append(num)

def update():
    pass

def draw():
    screen.clear()
    for n in nums:
        n.draw()

pgzrun.go()